<template>
    <el-form style="width: 60%"  ref="updateFormRef" :model="updateForm" label-width="100px" class="demo-ruleForm">
        <!-- 管理员注册码-->
        <el-form-item prop="id" label="管理员注册码:">
            <el-input v-model="updateForm.id"></el-input>
        </el-form-item>
        <div class="button" style=
                "display: flex;
         justify-content: flex-end;">
            <el-button  @click="update()" type="success">修改</el-button>
            <el-button  @click="reset()" type="info">重置</el-button>
        </div>
    </el-form>
</template>

<script>
    export default {
        methods:{
            update(){
                this.$confirm('此操作将修改该数据, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.$http.post("/register/updateAdminnum",this.updateForm.id)
                    this.$message({
                            type: 'success',
                            message: '修改成功!'
                        }
                    );
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消修改'
                    });
                });

            }
        },
        data() {
            return {
                //表单数据
                updateForm: {
                    id: null,
                }
            }
        },
        created() {
            //回车监听事件
            var _this = this;
            document.onkeydown = function(e) {
                let key = window.event.keyCode;
                if (key == 13) {
                    _this.login();
                }
            }
            //const _this = this
            this.$http.post("/register/selectAdminnum").then(function(resp){
                _this.updateForm.id=resp.data.adminnum
        })
        }
    }
</script>

<style scoped>

</style>